﻿using FanaticRock.Core.Models;
using System.ComponentModel;

namespace FanaticRock.Core.AudioPlay.Events
{
    public class PlayListChangedEventArgs : EventArgs
    {
        ///<summary>操作类型。</summary>
        public CollectionChangeAction Action { get; set; }

        public Song[] NewItems { get; private set; } = [];

        public Song[] OldItems { get; private set; } = [];

        public static PlayListChangedEventArgs CreateFromAdd(IEnumerable<Song> newItems)
        {
            return new PlayListChangedEventArgs()
            {
                Action = CollectionChangeAction.Add,
                NewItems = newItems.ToArray(),
            };
        }
        public static PlayListChangedEventArgs CreateFromDelete(IEnumerable<Song> oldItems)
        {
            return new PlayListChangedEventArgs()
            {
                Action = CollectionChangeAction.Remove,
                OldItems = oldItems.ToArray(),
            };
        }

        public static PlayListChangedEventArgs CreateFromReset()
        {
            return new PlayListChangedEventArgs()
            {
                Action = CollectionChangeAction.Refresh,
            };
        }
    }
}
